package com.jscloud.sparksql

import org.apache.spark.sql.SparkSession

object Demo {
  def main(args: Array[String]): Unit = {
    //创建 sparksession
    val spark = SparkSession.builder()
      .appName("demo1")
      .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
      .master("local[*]")
      .getOrCreate()

    val df = spark.read.text(this.getClass.getClassLoader.getResource("person.txt").getPath)

    //Prints the schema to the console in a  nice tree format
    //打印 schema 信息
    df.printSchema()

    println("----------------")
    println(df.count())

    println("------------------")
    df.show()

    spark.stop()

  }
}
